package com.example.services;

import com.example.bean.Person;
import com.example.dao.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by mengdexuan on 2017/3/1 11:19.
 */
@Service
public class ServicesTest {

	@Autowired
	PersonRepository personRepository;

	public String getStr(){
		return "abc"+ Math.random();
	}


	public String getStr2(){
		return Math.random()+"";
	}


	@Transactional
	public Person save(Person person){

		Person result = personRepository.save(person);

		if (1==1)
			throw new RuntimeException("异常发生了……");

		return result;
	}


}
